/* eslint-disable @typescript-eslint/no-explicit-any */
import React, { useRef,useContext, useEffect } from 'react';
import { storeContext } from '../../stories';
const AddName: React.FC<any> = () => {
    const inputRef = useRef<any>(null);
    const inputAgeRef = useRef<any>(null);
    const { state, dispatch } = useContext<any>(storeContext);
    // const {user} = state
    useEffect(()=>{
        console.log("我加载更新了,addName")
    })
    const handleChange = () => {
        const name = inputRef.current.value;
        dispatch({ type: 'CHANGENAME', name });
    };
    const handleAgeChange=()=>{
        const age = inputAgeRef.current.value
        dispatch({type:'CHANGEAGE',age})
    }
    return (
        <>
            <input ref={inputRef} value={state.user.name} onChange={handleChange} />
            <input ref={inputAgeRef} value={state.user.age} onChange={handleAgeChange} />
        </>
    );
};
export default AddName;
